Framework

Physical object in the game world.

Entities are physical representations of objects in the game world. Lilia extends the functionality of entities to interface between Lilia's own classes and to reduce boilerplate code.

See the Garry's Mod Wiki for all other methods that the Player class has.

Functions

entityMeta:SetCreator(client)

Assigns a creator to the entity.

Parameters

  • client Player

    The player to assign as the creator of the entity.

Example Usage

entity:SetCreator(player)

entityMeta:clearNetVars(receiver)

Internal

This is an internal function! You are able to use it, but you risk unintended side effects if used incorrectly.

Clears all of the networked variables.

Parameters

  • receiver Player

    The players to clear the networked variable for

Example Usage

entity:clearNetVars(player)

entityMeta:getEntItemDropPos()

Retrieves the drop position for an item associated with the entity.

Returns

  • Vector

    The drop position for the item.

Example Usage

local dropPos = entity:getEntItemDropPos()
print("Item drop position:", dropPos)

entityMeta:getNetVar(key, default)

Retrieves a networked variable. If it is not set, it'll return the default that you've specified.

Parameters

  • key String

    Identifier of the networked variable

  • default any

    Default value to return if the networked variable is not set

Returns

  • any

    The value associated with the key, or the default that was given if it doesn't exist

Example Usage

local example = entity:getNetVar("example", "Default Value")
print(example) -- Output: "Hello World!" or "Default Value"

See Also

entityMeta:getNetVar(key, default)

Retrieves the value of a networked variable associated with the entity.

Parameters

  • key String

    The identifier of the networked variable.

  • default any

    The default value to return if the networked variable does not exist.

Returns

  • any

    The value of the networked variable, or the default value if it doesn't exist.

Example Usage

local example = entity:getNetVar("example", "Default Value")
print(example) -- Output: "Hello World!" or "Default Value"

entityMeta:isItem()

Checks if the entity is an item entity.

Returns

  • Boolean

    True if the entity is an item entity, false otherwise.

Example Usage

if entity:isItem() then
    print("Entity is an item.")
end

entityMeta:isMoney()

Checks if the entity is a money entity.

Returns

  • Boolean

    True if the entity is a money entity, false otherwise.

Example Usage

if entity:isMoney() then
    print("Entity is money.")
end

entityMeta:isNearEntity(radius)

Checks if there is an entity near the current entity within a specified radius.

Parameters

  • radius Float

    The radius within which to check for nearby entities.

Returns

  • Boolean

    True if there is an entity nearby, false otherwise.

Example Usage

if entity:isNearEntity(150) then
    print("There is an entity nearby.")
else
    print("No entities within the specified radius.")
end

entityMeta:isProp()

Checks if the entity is a physics prop.

Returns

  • Boolean

    True if the entity is a physics prop, false otherwise.

Example Usage

if entity:isProp() then
    print("Entity is a physics prop.")
else
    print("Entity is not a physics prop.")
end

entityMeta:isSimfphysCar()

Checks if the entity is a simfphys car.

Returns

  • Boolean

    True if the entity is a simfphys car, false otherwise.

Example Usage

if entity:isSimfphysCar() then
    print("Entity is a simfphys car.")
end

entityMeta:sendNetVar(key, receiver)

Internal

This is an internal function! You are able to use it, but you risk unintended side effects if used incorrectly.

Sends a networked variable.

Parameters

  • key String

    Identifier of the networked variable

  • receiver Player

    The players to send the networked variable to

Example Usage

entity:sendNetVar("health", player)

entityMeta:setNetVar(key, value, receiver)

Sets the value of a networked variable.

Parameters

  • key String

    Identifier of the networked variable

  • value any

    New value to assign to the networked variable

  • receiver Player

    The players to send the networked variable to

Example Usage

entity:setNetVar("example", "Hello World!", player)

See Also